from datetime import datetime, date
from flask.json.provider import DefaultJSONProvider, _default as flask_json_default

import typing as t


def _default(o: t.Any) -> t.Any:
    if isinstance(o, datetime):
        return o.strftime('%Y-%m-%d %H:%M:%S')
    elif isinstance(o, date):
        return o.strftime('%Y-%m-%d')

    return flask_json_default(o)


class MyJSONProvider(DefaultJSONProvider):
    default: t.Callable[[t.Any], t.Any] = staticmethod(_default)
